<?php

/**
 * Person form base class.
 *
 * @method Person getObject() Returns the current form's model object
 *
 * @package    makethetouch
 * @subpackage form
 * @author     Sebastien Chassande-Barrioz
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BasePersonForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'login'            => new sfWidgetFormInputHidden(),
      'first_name'       => new sfWidgetFormInputText(),
      'last_name'        => new sfWidgetFormInputText(),
      'email'            => new sfWidgetFormInputText(),
      'phone_mobile'     => new sfWidgetFormInputText(),
      'phone_2'          => new sfWidgetFormInputText(),
      'country'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Country'), 'add_empty' => false)),
      'referee_level'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('RefereeLevel'), 'add_empty' => true)),
      'address'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Address'), 'add_empty' => true)),
      'my_club'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Club'), 'add_empty' => true)),
      'password'         => new sfWidgetFormInputText(),
      'status'           => new sfWidgetFormInputText(),
      'level'            => new sfWidgetFormInputText(),
      'subscriptiondate' => new sfWidgetFormDateTime(),
      'subscriptionip'   => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'login'            => new sfValidatorChoice(array('choices' => array($this->getObject()->get('login')), 'empty_value' => $this->getObject()->get('login'), 'required' => false)),
      'first_name'       => new sfValidatorString(array('max_length' => 30)),
      'last_name'        => new sfValidatorString(array('max_length' => 30)),
      'email'            => new sfValidatorString(array('max_length' => 100)),
      'phone_mobile'     => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'phone_2'          => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'country'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Country'))),
      'referee_level'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('RefereeLevel'), 'required' => false)),
      'address'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Address'), 'required' => false)),
      'my_club'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Club'), 'required' => false)),
      'password'         => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'status'           => new sfValidatorInteger(),
      'level'            => new sfValidatorInteger(),
      'subscriptiondate' => new sfValidatorDateTime(array('required' => false)),
      'subscriptionip'   => new sfValidatorString(array('max_length' => 50, 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('person[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Person';
  }

}
